<?php


namespace app\reception\controller;


use think\App;
use think\Controller;

class ToolApi extends Controller
{
    public $package;

    public function __construct(App $app = null)
    {
        $this->package = request()->header("x-quick-package");
        if (!$this->package) {
//            errJson("quick app is null")->send();
//            die;
        }
        parent::__construct($app);
    }


    public function wallpaperList()
    {
        $page = input('page', 1);
        $limit = input('limit', 10);
        $jsonStr = '[{"name":"高清手机锁屏壁纸来啦!","file":"/quick_cms/tool_imgs/00dc330a5d32ded3047895f221bc2a2d.jpg"},{"name":"壁纸| 全面屏壁纸_自由_人间_年年","file":"/quick_cms/tool_imgs/0946a5029d4aca324681334c62eeae17.jpeg"},{"name":"手机壁纸|紫色系壁纸,无水印免费分享!","file":"/quick_cms/tool_imgs/11f56a0ea2b4cb64d41b657ba1ca48a2.jpg"},{"name":"高清手机锁屏壁纸来啦!","file":"/quick_cms/tool_imgs/13e6ec8966db94b9b68e6d7cd8ea6e00.jpg"},{"name":"手机壁纸|好看的简约壁纸","file":"/quick_cms/tool_imgs/148c0f540252ebd20f5543080088dfda.jpeg"},{"name":"极简风高清壁纸图片","file":"/quick_cms/tool_imgs/17531ad6296c3bd510d8a94155375d53.jpg"},{"name":"壁纸|‎ 两手空空 才能无限拥有","file":"/quick_cms/tool_imgs/1b57f1a70957264291092e4b130acd92.jpeg"},{"name":"要有好看的壁纸呀!","file":"/quick_cms/tool_imgs/1b94f5f44058646a4cfed3b328150734.jpeg"},{"name":"壁纸| 𝙎𝙃𝘼𝙍𝙀 -被赞爆的手机壁纸","file":"/quick_cms/tool_imgs/213a0a064459a70142358e0c88ca652b.jpg"},{"name":"#春日星能量##壁纸##本周狗屎运最旺的星座#","file":"/quick_cms/tool_imgs/2291935739d3514f971164d969415e39.jpeg"},{"name":"春花壁纸上新!故宫杏花开放好浪漫","file":"/quick_cms/tool_imgs/22d6e1597f17486a7946ad1ee124f96b.jpeg"},{"name":"iphone壁纸高清 | 今日大吉 万事皆宜_程序_刘亦菲_下拉","file":"/quick_cms/tool_imgs/2704e41268dfb252660e559c3e6a0029.jpg"},{"name":"壁纸| 超级有意思的手机壁纸来啦","file":"/quick_cms/tool_imgs/2cf8fdc5a2937c78c751eaac246f0ca9.jpeg"},{"name":"极简风手机高清壁纸","file":"/quick_cms/tool_imgs/378a0492b323afbb80fe157f477fff1d.jpeg"},{"name":"壁纸分享,宁愿在风中凌乱起舞,也不愿在雨中狼狈哭泣","file":"/quick_cms/tool_imgs/3839b24752827580f002cba213086e01.jpeg"},{"name":"一些可爱的头像和壁纸_人生_时候_happy","file":"/quick_cms/tool_imgs/3e5fe6b7ef2bf6868c2b006bf38f93c1.jpg"},{"name":"壁纸| 精选壁纸 请查收!","file":"/quick_cms/tool_imgs/4fb0dc25d62d7960966f6fe6f99ff74b.jpg"},{"name":"壁纸分享,你喜欢粉色吗","file":"/quick_cms/tool_imgs/5370ef596fb9a13d3ea1adeef9810a5b.jpeg"},{"name":"#无水印动漫壁纸#","file":"/quick_cms/tool_imgs/54bf114d8dd10ffd6d66c199b36a03ad.jpg"},{"name":"诸事皆安好,快换上新壁纸!","file":"/quick_cms/tool_imgs/557bd21dfbcbf81ba0eaf0f94cadff76.jpg"},{"name":"很棒的一组治愈风景锁屏壁纸","file":"/quick_cms/tool_imgs/5d87e38d3655625307671988c1be83e4.jpg"},{"name":"壁纸| 精选可爱卡通锁屏壁纸_loveeee","file":"/quick_cms/tool_imgs/60949653eef5d372f82197fa42b80a1f.jpeg"},{"name":"一期山水画壁纸𝗪𝗲𝗖𝗵𝗮𝘁好有意境美","file":"/quick_cms/tool_imgs/65b9f9c0087fd9c0cb90d2491bc8c4ff.jpeg"},{"name":"#每日桌面#","file":"/quick_cms/tool_imgs/6b0a360e1c85840e90bc105135bb8af8.jpg"},{"name":"壁纸分享,你喜欢粉色吗","file":"/quick_cms/tool_imgs/6efa1edd694db0092e3255b79ce83c44.jpeg"},{"name":"壁纸分享,别让忧虑遮挡住阳光,让快乐成为你生活的底色","file":"/quick_cms/tool_imgs/70ee542c5f6d1e7d76661e174ac81f21.jpeg"},{"name":"iphone壁纸 | 高清壁纸精选","file":"/quick_cms/tool_imgs/8335ab960e8373860dfa73fab9b10668.jpg"},{"name":"#治愈人心的猫猫壁纸##vista小可爱#","file":"/quick_cms/tool_imgs/8472e52fa98b45c51475171284467a6d.jpg"},{"name":"3.4 | 小头像 壁纸_苦难_世界_谷地","file":"/quick_cms/tool_imgs/863808cbc7f6cfbd881d00d5338c2314.jpeg"},{"name":"#无水印动漫壁纸#","file":"/quick_cms/tool_imgs/87968b076a24b0359730afa7689e19cf.jpg"},{"name":"#每日桌面#","file":"/quick_cms/tool_imgs/8d33f838a635e76b3902923c734aab0b.jpeg"},{"name":"竖屏大图[全屏壁纸～漫篇]","file":"/quick_cms/tool_imgs/911432b842ab9411298dc975a137e1fc.jpeg"},{"name":"热门抖音壁纸_图文","file":"/quick_cms/tool_imgs/970d30aeb52e2c0f144f18d8c51d0302.jpeg"},{"name":"#每日桌面#","file":"/quick_cms/tool_imgs/9bcdd6f2d5dce74ce6f60d0dc7c47605.jpg"},{"name":"手机壁纸_emo","file":"/quick_cms/tool_imgs/9f1a498abe0126b6fbf6664775f43b8b.jpeg"},{"name":"我有密集恐惧症 不能接近心眼子多的人#插画##插画头像##情话##壁纸##","file":"/quick_cms/tool_imgs/a2b4907efed6584b6fe0fd39de0c8197.jpeg"},{"name":"色调清新自然的竖屏手机壁纸","file":"/quick_cms/tool_imgs/a55267de1261240b84f4d1c4eae7c716.jpg"},{"name":"梦幻花卉摄影唯美高清手机壁纸_植物","file":"/quick_cms/tool_imgs/a6ccb62cb0d0d2b6de3f8f997efb751f.jpeg"},{"name":"清新唯美梦幻粉红卡通场景高清手机壁纸","file":"/quick_cms/tool_imgs/acf56b664c938d29a61c3f99f33e79b4.jpeg"},{"name":"ai动画真的很棒,总有一款壁纸属于你","file":"/quick_cms/tool_imgs/b054f2e33ce6a57c75f13363ff5032e8.jpeg"},{"name":"冬日唯美白色雪景高清图片手机壁纸_风景","file":"/quick_cms/tool_imgs/b4891e999ab25adac2e9b4552866939b.jpeg"},{"name":"壁纸 背景 _ 图片网","file":"/quick_cms/tool_imgs/cb254d6282a57bdbeab443bcd91a7cba.jpeg"},{"name":"小众风格唯美高清手机壁纸-风格","file":"/quick_cms/tool_imgs/cd775fa7b464d7c85b75691e87b8594c.jpeg"},{"name":"大海唯美风景高清手机壁纸-风景","file":"/quick_cms/tool_imgs/d043d7bf2206c71322ff7e977515c934.jpeg"},{"name":"#我的桌面iscreen##聊天背景图#","file":"/quick_cms/tool_imgs/dbab4762a9ad7d0faa5fbad8f71e8431.jpg"},{"name":"粉色唯美手机壁纸 唯美聊天背景图_唯美图片","file":"/quick_cms/tool_imgs/dd17f7ab8e686f77c0995baba4c89dae.jpeg"},{"name":"#每日桌面#","file":"/quick_cms/tool_imgs/de9883d088b8a4d3a1a7b2d486cbc81b.jpeg"},{"name":"iphone x全面屏壁纸_deep","file":"/quick_cms/tool_imgs/df65338f27ca2346b95da0f11c9a6d8e.jpeg"},{"name":"唯美秀丽的自然风光图片手机壁纸_风景","file":"/quick_cms/tool_imgs/e058a9d99a6eefe7183263736b8dc568.jpg"},{"name":"发一些唯美的1440*2560竖屏壁纸","file":"/quick_cms/tool_imgs/e27c95e98c1ed0d7e293cb2caf93a7d4.jpg"},{"name":"风景 街景 旅行 美景 鲜花 清新 摄影 田园…","file":"/quick_cms/tool_imgs/e52691bb70c9dbc0d870301b722e5c52.png"},{"name":"高清4k 竖屏 壁纸 推荐","file":"/quick_cms/tool_imgs/e71c3305fabbc58e717880e0f2967655.jpg"},{"name":"洋桔梗小清新养眼静物写真,锁屏图片,手机壁纸,植物","file":"/quick_cms/tool_imgs/e8938ea246e767658823ac406f194d76.jpg"},{"name":"小清新花卉图片手机壁纸-植物","file":"/quick_cms/tool_imgs/ea10c2e6c9e0dddf9a95cd2b2ee66b88.jpeg"},{"name":"可爱到爆壁纸|因为生活值得,所以频繁记录","file":"/quick_cms/tool_imgs/eadf77b20728f06bd45abc30739a989b.jpg"},{"name":"#无水印动漫壁纸#","file":"/quick_cms/tool_imgs/ec0b9fce743b1cb13b5abd20a9f5cab6.jpg"},{"name":"#每日桌面#","file":"/quick_cms/tool_imgs/efb5ef385189876db0d0985b117dc2b2.jpeg"},{"name":"新年壁纸","file":"/quick_cms/tool_imgs/f123ee875aeb02de8cba052e624aeb73.jpg"},{"name":"#花#高清壁纸","file":"/quick_cms/tool_imgs/f9756b458bbe39a0ff832020c38a6de0.jpg"}]';
        $arr = json_decode($jsonStr, true);


        // 每页显示的项数
        $perPage = $limit;
        $allCount = count($arr);
        // 计算总页数
        $totalPages = ceil($allCount / $perPage);
        // 从请求中获取当前页码，默认为第一页
        $currentPage = $page;

        // 确保当前页码在有效范围内
        if ($currentPage > $totalPages){
            return sucJson([], $allCount);
        }

        // 使用 array_slice 获取当前页的数据
        $offset = ($currentPage - 1) * $perPage;
        $currentPageItems = array_slice($arr, $offset, $perPage);

        // 输出当前页的数据
        foreach ($currentPageItems as $k => $v) {
            $currentPageItems[$k]['file'] = config('img_domain') . $v['file'];
        }
        return sucJson($currentPageItems, $allCount);
    }
}